<form id="fm" action="http://localhost:54959/Home/_Export" method="POST">
    <input type="hidden" id="exportString" name="svg"/>
    <input type="hidden" id="exportFormat" name="format"/>
</form>

<div id="chart"></div>
<div id="grid"></div>
<button id="export" class="k-button" data-format="png">Export</button>
<button id="export2" class="k-button" data-format="png">Export2</button>
<img id="image" />
<div id="t"></div>


<script>
    function createChart() {
        $("#chart").kendoChart({
            theme: $(document).data("kendoSkin") || "default",
            title: {
                text: "Internet Users"
            },
            legend: {
                position: "bottom"
            },
            chartArea: {
                //It's important that your background NOT be transparent for proper exporting
                //of some file types - most noticeably Jpeg
                background: "white"
            },
            seriesDefaults: {
                type: "line"
            },
            series: [
                {
                    name: "World",
                    data: [15.7, 16.7, 20, 23.5, 26.6]
                },
                {
                    name: "United States",
                    data: [20.96, 20.93, 75, 74, 78]
                },
                {
                    name: "China",
                    data: [10, .93, 7, 7, 2],
                }
            ],
            valueAxis: {
                labels: {
                    format: "{0}%"
                }
            },
            categoryAxis: {
                categories: [2005, 2006, 2007, 2008, 2009]
            },
            tooltip: {
                visible: true,
                format: "{0}%"
            }
        });


    }

    $(document).ready(function () {
        createChart();

        $("#grid").kendoGrid({
            dataSource: {
                transport: {
                    read: "../Shooter/GetUserStageInfo"
                },
                schema: {
                    data: "data"
                }
            },
            columns: [
                { field: "score" },
                { field: "level" }
            ]
        });
        $("#export").click(function () {
            var chart = $("#chart").data("kendoChart");
            var svgString = escape(chart.svg());
            var exportFormat = $(this).data("format");

            $("#exportString").val(svgString);
            $("#exportFormat").val(exportFormat);
            $("#fm").submit();
        });
        $("#export2").click(function () {
            var chart = $("#chart").data("kendoChart");
            var svgString = escape(chart.svg());
            var exportFormat = $(this).data("format");
            //var datat = "{" + "\"svg\":\"" + svgString + "\",\"format\":\"" + exportFormat + "\"}";
            data = {};
            data.svg = svgString;
            data.format = exportFormat;
            $.ajax(
                {
                    url: "../Api/GetImageUrl",
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (result) {
                        console.log(result.url);
                        $("#image")[0].src = result.url;
                        $("#t").html('\<script\>alert("123");\<\/script\>');
                    },
                    error: function () {
                        console.log(result)
                    }
                }
            )
        });
        $.ajax(
            {
                url: "../Content/Test",
                type: "POST",
                success: function (result) {
                    $("#t").html(result);
                },
                error: function () {
                    console.log(result)
                }
            }
        )

    })
    ;
</script>